﻿using System;
using System.Windows.Forms;

namespace RSkor.Common.WinForms
{
    /// <summary>
    /// 
    /// </summary>
    public class FlowLayoutBreak : System.Windows.Forms.Control
    {
        private bool _break = true;
        public bool Break
        {
            get
            {
                return _break;
            }
            set
            {
                _break = value;
            }
        }

        protected override void OnParentChanged(EventArgs e)
        {
            base.OnParentChanged(e);
            if (Parent != null && Parent is FlowLayoutPanel)
            {
                int idx = Parent.Controls.IndexOf(this);
                if (idx > 0 && !(Parent.Controls[idx - 1] is FlowLayoutBreak))
                {
                    (Parent as FlowLayoutPanel).SetFlowBreak(Parent.Controls[idx - 1], Break);
                    Parent = null;
                }
            }
        }
    }
}
